﻿
    <div ms-controller="INFO">

        <ul class="sui-nav nav-tabs nav-xlarge">
            <li ms-class="active:ltype=='1'" ms-click="SelLayer(1)"><a>新增大楼</a></li>
            <li  ms-class="active:ltype=='2'" ms-click="SelLayer(2)"><a>增加指定楼层</a></li>
        </ul>
        <div id="tabl1" ms-visible="ltype=='1'">
            <div class="control-group">
                <label class="control-label">大楼名称：</label>
                <div class="controls">
                    <input class="input-xlarge input-xfat" placeholder="比如1号楼" type='text' ms-duplex="modelData.LouNo" data-rules="required|minlength=1|maxlength=50" id="txtLouNo" />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">最高楼层：</label>
                <div class="controls">
                    <input class="input-xlarge input-xfat" placeholder="请输入最高楼层" type='number' ms-duplex="modelData.LouNum" data-rules="required|minlength=1|maxlength=100" id="txtLouNum" />
                </div>
            </div>
            <!--<div class="control-group">
                <label class="control-label">备注：</label>
                <div class="controls">
                    <input class="input-xlarge input-xfat" placeholder="请输入备注" type='text' ms-duplex="modelData.Remark"   />
                </div>
            </div>-->
        </div>

        <div id="tabl2" ms-visible="ltype=='2'">
            <div class="control-group">
                <label class="control-label">选择大楼：</label>
                <div class="controls">
                    <select class="input-medium input-xfat" ms-duplex="modelData2.ID">
                        <option ms-repeat-el="LouList" ms-attr-value="el.ID">{{el.LouNo}}</option>
                    </select>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">楼层：</label>
                <div class="controls">
                    <input class="input-xlarge input-xfat" placeholder="请输入楼层" type='number' ms-duplex="modelData2.LouNum" data-rules="required|minlength=1|maxlength=100"  />
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">安装位置：</label>
                <div class="controls">
                    <input class="input-xlarge input-xfat" placeholder="请输入备注" type='text' ms-duplex="modelData2.Remark"  />
                </div>
            </div>
        </div>
    </div>

<script type="text/javascript">

    var tempmodel = avalon.define({
        $id: "INFO",
        authData: [],
        modelData: { "ID": "0", "LouNo": "", "LouNum": "", "Remark": "" },
        modelData2: { "ID": "", "LouNo": "", "LouNum": "", "Remark": "" },
        ltype: "1",
        LouList:[],
        inittemp: function (strId) {
            $.getJSON(ComFunJS.APIURL("BASE_GETLOU"), function (r) {
                if (r.error == "") {
                    tempmodel.LouList = r.result;

                }
            })

            //if (strId) {
            //    ComFunJS.getJSON("BASE_GETROLEMODEL", { "P1": strId }, function (r) {
            //        if (r.error == "") {
            //            tempmodel.modelData = r.result;


            //        }

            //    })

            //} else {
            //    ComFunJS.initForm();
            //}



        },
        SaveData: function (dom, formtype, status) {
            if (tempmodel.ltype == "1") {
                ComFunJS.postJSON("BASE_ADDLOU", { "P1": tempmodel.modelData.LouNo, "P2": tempmodel.modelData.LouNum }, function (r) {
                    if (r.error == "") {
                        top.ComFunJS.winShowMsg("添加成功");
                        top.ComFunJS.close();
                    } else {
                        top.ComFunJS.winShowMsg(r.error);
                    }
                })
            } else {
                ComFunJS.postJSON("BASE_ADDLAYC", { "P1": tempmodel.modelData2.ID, "P2": tempmodel.modelData2.LouNum, "Remark": tempmodel.modelData2.Remark }, function (r) {
                    if (r.error == "") {
                        top.ComFunJS.winShowMsg("添加成功");
                        top.ComFunJS.close();
                    } else {
                        top.ComFunJS.winShowMsg(r.error);
                    }
                })
            }
        },
        SelLayer: function (t) {
            tempmodel.ltype = t;
        }


    })

</script>
